package com.ruoyi.project.system.service.impl;

import java.util.*;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.MiddleTableData;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.system.mapper.TMultiselMapper;
import com.ruoyi.project.system.domain.TMultisel;
import com.ruoyi.project.system.service.ITMultiselService;

/**
 * 多选题库 Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-05-09
 */
@Service
public class TMultiselServiceImpl implements ITMultiselService 
{
    @Autowired
    private TMultiselMapper tMultiselMapper;

    /**
     * 查询多选题库 
     * 
     * @param multiselId 多选题库 ID
     * @return 多选题库 
     */
    @Override
    public TMultisel selectTMultiselById(Integer multiselId)
    {
        return tMultiselMapper.selectTMultiselById(multiselId);
    }

    /**
     * 查询多选题库 列表
     * 
     * @param tMultisel 多选题库 
     * @return 多选题库 
     */
    @Override
    public List<TMultisel> selectTMultiselList(TMultisel tMultisel)
    {
        return tMultiselMapper.selectTMultiselList(tMultisel);
    }

    /**
     * 新增多选题库 
     * 
     * @param tMultisel 多选题库
     * @return 结果
     */
    @Override
    public int insertTMultisel(TMultisel tMultisel)
    {
        tMultisel.setCreateTime(DateUtils.getNowDate());
        return tMultiselMapper.insertTMultisel(tMultisel);
    }

    /**
     * 修改多选题库 
     * 
     * @param tMultisel 多选题库 
     * @return 结果
     */
    @Override
    public int updateTMultisel(TMultisel tMultisel)
    {
        return tMultiselMapper.updateTMultisel(tMultisel);
    }

    /**
     * 批量删除多选题库 
     * 
     * @param multiselIds 需要删除的多选题库 ID
     * @return 结果
     */
    @Override
    public int deleteTMultiselByIds(Integer[] multiselIds)
    {
        deleteTMultiselBMiddle(multiselIds[1],multiselIds[0]);
        return tMultiselMapper.deleteTMultiselByIds(multiselIds);
    }

    /**
     * 删除多选题库 信息
     * 
     * @param multiselId 多选题库 ID
     * @return 结果
     */
    @Override
    public int deleteTMultiselById(Integer multiselId)
    {
        return tMultiselMapper.deleteTMultiselById(multiselId);
    }


    @Override
    public int addTMultiselBMiddle(Integer  subject_id ,Integer multiSel_id) {
        MiddleTableData middleTableData = new MiddleTableData();
        return tMultiselMapper.addTMultiselBMiddle(middleTableData.FZMap(subject_id,multiSel_id));
    }

    @Override
    public int updateTMultiselBMiddle(Integer  subject_id ,Integer multiSel_id,String courseName) {
        MiddleTableData middleTableData = new MiddleTableData();
        Map map = middleTableData.FZMap(subject_id, multiSel_id);
        map.put("courseName",courseName);
        return tMultiselMapper.updateTMultiselBMiddle(map);
    }

    @Override
    public int deleteTMultiselBMiddle(Integer  subject_id ,Integer multiSel_id) {

        MiddleTableData middleTableData = new MiddleTableData();
        return tMultiselMapper.deleteTMultiselBMiddle(middleTableData.FZMap(subject_id,multiSel_id));
    }

}
